<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/2/24
 * Time: 9:43
 */
class Model_Insurance extends  PhalApi_Model_NotORM{
    protected function getTableName($id){
        return 'p_insurance';
    }

    /**
     * 保存表单信息
     */
    public function addInsurance($obj){
        $data=array(
            'uname' => $obj->uname,
            'phone' => $obj->phone,
            'id_no'  => $obj->id_no,
            'createtime' => time(),
        );
        return $this->getORM()->insert($data);
    }
    /**
     * 判断一个手机号当天是否已保存过表单
     */
    public function isInsuranceExists($obj){
        $time = date('Ymd',time());
        $phone=$obj->phone;
        return $this->getORM()->select('*')->where("phone=? and FROM_UNIXTIME(createtime,'%Y%m%d')=$time",$phone)->fetchRow();
    }
}